const { contextBridge, ipcRenderer } = require('electron')

contextBridge.exposeInMainWorld('versions', {
	node: process.versions.node,
	chrome: process.versions.chrome,
	electron: () => process.versions.electron,
	// 能暴露的不仅仅是函数，我们还可以暴露变量
});

contextBridge.exposeInMainWorld('invoke', ipcRenderer.invoke);
contextBridge.exposeInMainWorld('send', ipcRenderer.send);
contextBridge.exposeInMainWorld('on', ipcRenderer.on);

window.addEventListener('DOMContentLoaded', () => {
	const replaceText = (selector, text) => {
		document.querySelector(selector).innerHTML = text;
	}
	['chrome', 'node', 'electron'].forEach(dependency => {
		replaceText(`#${dependency}-version`, process.versions[dependency]);
	});
	//document.querySelector('#version').innerHTML = process.app_version;

});